package com.peza.bikelog.common.domain.polar;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

import com.peza.bikelog.common.util.Util;

public class HrmIntNotes implements Writable{

	private static Util util = Util.getInstance();
	
	private Map<String,String> lapNotes = new HashMap<String,String> ();
	
	public HrmIntNotes(String data) {
		String [] lines = data.split("\n");
		
		for (String line : lines){
			String [] fields = line.split("\t");
			String lap = fields[0];
			String note = "";
			try {
				note = fields[1];
			} catch (ArrayIndexOutOfBoundsException e) {
				// do  nothing
			}
			lapNotes.put(lap, note);
		}
	}

	@Override
	public String toFileString() {
		StringBuffer buffer = new StringBuffer("[IntNotes]\n");
		
		Set<Map.Entry<String,String>>entries = lapNotes.entrySet();
		for (Map.Entry<String,String> entry : entries){
			buffer.append(entry.getKey() + "\t" + entry.getValue());
		}

		buffer.append("\n");
		return buffer.toString() + "\n";
	}

	
	
	
}
